home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / bc_ti / ti640.asc < prev    next >
Text File  |  1992-02-24  |  967b  |  67 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  C++                                    NUMBER  :  640
  9.   VERSION  :  All
  10.        OS  :  PC DOS
  11.      DATE  :  February 25, 1992                        PAGE  :  1/1
  12.  
  13.     TITLE  :  Precision and Decimal Places in iostreams
  14.  
  15.  
  16.  
  17.  
  18.   Given a real variable  x  (either float or double) with value 2.0
  19.   and also given a real variable PI = 3.1415926...
  20.  
  21.   ---- OUTPUT ----   ------------- STATEMENT ---------------
  22.  
  23.   "x == 2"             cout<<"x == "<<x;
  24.  
  25.   "x==2.00"            cout<<setprecision(3)
  26.                            <<setiosflags(ios::showpoint)
  27.                            <<"x == "<<x;
  28.  
  29.   "x == "02.0"         cout<<setw(4)<<setfill('0')
  30.                            <<setprecision(2)
  31.                            <<"x == "<<x;
  32.  
  33.   "pi == 3.14"         cout<<setprecision(3)<<"pi == "<<pi;
  34.  
  35.   "pi == 3.1416"       cout<<setprecision(5)<<"pi == "<<pi;
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.